package 分类.双指针;

import java.util.Arrays;

public class 移动零 {
    public static void moveZeroes(int[] nums) {
       int slow=0,fast=0;
       while (fast<nums.length){
           if(nums[fast]!=0){
               nums[slow]=nums[fast];
               slow++;
           }
           fast++;
       }
        System.out.println(slow);
       if(slow<nums.length){
           Arrays.fill(nums,slow,nums.length,0);
       }
    }

    public static void main(String[] args) {
       int[] nums={0,1,0,3,12};
       moveZeroes(nums);

    }
}
